#encoding:utf8 

''' 2018-2-3 crt '''

from init_bin import Dw as d
import os
import sys

try:
    import psutil
except ImportError as identifier:
    d.logger().error(identifier)
    sys.exit()

class PiStatau(object):

    _baseinfo = dict(
        cpunum = None,   #cup数量
        memper = None   #内存占用百分比
    )

    @classmethod 
    def base(cls):
        ''' 设备基础属性 '''
        d.logger().info("Get pi base status ...")   
        cls._baseinfo["cpunum"] = psutil.cpu_count()
        mem = psutil.virtual_memory()
        print (mem,"--->>mem")
        cls._baseinfo["memper"] = "%.2f" % (float(mem.used) / float(mem.total))
        return cls._baseinfo

        

if __name__ == "__main__":
    baseinfo = PiStatau.base()
    print baseinfo